#![allow(non_camel_case_types)]
#![allow(dead_code)]
pub mod arkts;
pub mod kits;
pub mod ohos;

mod es;

pub use es::*;

use napih::Value;

#[macro_export]
macro_rules! IMPL_NAPI {
	($TY:ident,$EXT:ident) => {
		IMPL_NAPI!($TY<>, $EXT<>);
	};
	($TY:ident<$($T:ident),*>,$EXT:ident) => {
		IMPL_NAPI!($TY<$($T),*>, $EXT<>);
	};
	($TY:ident<$($T:ident),*>,$EXT:ident<$($TE:ident),*>) => {
		impl<'val, $($T),*> $TY<'val, $($T),*> {
			pub fn _new(v: Value<'val>) -> Self {
				Self($EXT::<$($TE),*>::_new(v), $(core::marker::PhantomData::<$T>::default()),*)
			}
		}
		impl<'val, $($T),*> napih::FromNapi<'val> for $TY<'val, $($T),*> {
			fn from_napi(v: Value<'val>) -> napih::Result<'static, Self> {
				Ok(Self::_new(v))
			}
		}
		impl<'val, $($T),*> napih::IntoNapi for $TY<'val, $($T),*> {
			fn into_napi<'env>(self, env: &'env napih::Env) -> napih::Result<'static, Value<'env>> {
				Ok(Value::new(env, self.0.raw()))
			}
		}
		impl<'val, $($T),*> core::ops::Deref for $TY<'val, $($T),*> {
			type Target = $EXT<'val, $($TE),*>;
			fn deref(&self) -> &Self::Target {
				&self.0
			}
		}
	};
}

pub trait InterFace<'val>: napih::FromNapi<'val> {
	fn v(&self) -> Value<'val>;
}

pub struct number<'val>(pub Value<'val>);
IMPL_NAPI!(number, Value);

pub type string = String;
pub type boolean = bool;
